import request from '@/utils/request'
import requestFile from '@/utils/request-file'
import { formatDateByFmt } from '@/utils/util.js'

const prefixUrl = 'web/report/'

// 获取周历表
export function week_summary(params) {
  return request({
    url: prefixUrl + 'week-summary',
    method: 'get',
    params
  })
}

// 获取周历表项目详情
export function week_detail(params) {
  return request({
    url: prefixUrl + 'week-detail',
    method: 'get',
    params
  })
}

// 获取上画率总表
export function draw_rate_summary(params) {
  return request({
    url: prefixUrl + 'draw-rate-summary',
    method: 'get',
    params
  })
}

/**
 * 获取电梯智能框分表数据
 * @param params
 * @returns {AxiosPromise}
 */
export function draw_rate_detail_elevator(params) {
  return request({
    url: prefixUrl + 'draw-rate-detail-elevator',
    method: 'get',
    params
  })
}

/**
 * 获取加油站分表数据
 * @param params
 * @returns {AxiosPromise}
 */
export function draw_rate_detail_gas_station(params) {
  return request({
    url: prefixUrl + 'draw-rate-detail-gas-station',
    method: 'get',
    params
  })
}

/**
 * 获取通用类型分表数据
 * @param params
 * @returns {AxiosPromise}
 */
export function draw_rate_detail_common(params) {
  return request({
    url: prefixUrl + 'draw-rate-detail-common',
    method: 'get',
    params
  })
}

/**
 * 获取楼宇类型的分表
 * @param params
 * @returns {AxiosPromise}
 */
export function draw_rate_detail_building(params) {
  return request({
    url: prefixUrl + 'draw-rate-detail-building',
    method: 'get',
    params
  })
}

// 导出点位Excel
export function export_buildings(data) {
  return requestFile({
    url: prefixUrl + '/export-buildings',
    method: 'post',
    content_type: 'json',
    data,
    fileName: '周历导出' + (formatDateByFmt(new Date(), 'yyyyMMddhhmmss') + Math.floor(Math.random() * (
      1000000 -
      1) + 1)) + '.zip'
  })
}

// 导出点位Excel到1个excel
export function export_buildings_to_one(data) {
  return requestFile({
    url: prefixUrl + '/export-buildings-to-one',
    method: 'post',
    content_type: 'json',
    data,
    fileName: '周历导出' + (formatDateByFmt(new Date(), 'yyyyMMddhhmmss') + Math.floor(Math.random() * (
      1000000 -
      1) + 1)) + '.xls'
  })
}